package com.core.domain;

import com.core.enums.ResultCode;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;


/**
 * 返回列表结构
 */

@Getter
@Setter
public class TableDataInfo {
    /**
     * 题目总数
     */
    private Long total;

    /**
     * 题目列表
     */
    private List<?> rows;

    /**
     * 状态码
     */
    private int code;

    /**
     * 描述
     */
    private String msg;


    public static TableDataInfo empty(){
        TableDataInfo tableDataInfo=new TableDataInfo();
        tableDataInfo.setCode(ResultCode.SUCCESS.getCode());
        tableDataInfo.setMsg(ResultCode.SUCCESS.getMsg());
        tableDataInfo.setTotal(0L);
        tableDataInfo.setRows(new ArrayList<>());
        return tableDataInfo;
    }


    public static TableDataInfo success(List<?> rows,Long total){
        TableDataInfo tableDataInfo=new TableDataInfo();
        tableDataInfo.setCode(ResultCode.SUCCESS.getCode());
        tableDataInfo.setMsg(ResultCode.SUCCESS.getMsg());
        tableDataInfo.setTotal(total);
        tableDataInfo.setRows(rows);
        return tableDataInfo;
    }
}
